<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>操作日志</title>
	<!--[if IE]>
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<![endif]-->
	<!-- Main Stylesheet --> 
	<link rel="stylesheet" href="<%=request.getContextPath()%>/css/style.css" type="text/css" />
	<!-- Your Custom Stylesheet --> 
	<link rel="stylesheet" href="<%=request.getContextPath()%>/css/custom.css" type="text/css" />
	<link href="<%=request.getContextPath()%>/lib/thickbox/thickbox.css" rel="stylesheet" type="text/css" />
	<link href="<%=request.getContextPath()%>/lib/jquery/jquery.autocomplete.css" type="text/css" rel="stylesheet"/>
	<%@include file="/include/header.jsp" %>
	<script src="<%=request.getContextPath()%>/lib/jquery/jquery-1.4.2.min.js"></script>
	<script src="<%=request.getContextPath()%>/js/administry.js"></script>
	<script src="<%=request.getContextPath()%>/lib/datepicker/WdatePicker.js"></script>
	<script src="<%=request.getContextPath()%>/lib/thickbox/thickbox.js"></script>
	<script src="<%=request.getContextPath()%>/lib/jquery/jquery.autocomplete.pack.js"></script>
	<script src="<%=request.getContextPath()%>/js/function.js"></script>
	<script src="<%=request.getContextPath()%>/js/page/pageRender.js"></script>
	<script type="text/javascript">
		
		window.onload = init;
		function init(){
			window["pr"] = new PageRender({
				id: 'pr',
				method: 'POST',
				url:'<%=request.getContextPath()%>/protected/system/listActionLog.action',
				start: <s:property value="start"/>,
				limit: <s:property value="limit"/>,
				total: <s:property value="total"/>,
				renderTo: 'page_bar',
				data:{
					"actionName": "#s_actionName",
					"userName": "#s_userName",
					"startDate": "#s_startDate",
					"endDate": "#s_endDate",
					"orderby": "#orderby"
				}
			});
		}
		function doSearch(){
			Mask.show();
			window["pr"].position(1);
		}
		<sec:authorize ifAnyGranted="ADMIN,ACTIONLOG_DELETE">
		function del(){
			var es = document.getElementsByName('code_cbx');
			var ids = [];
			for(var i=0; i<es.length; i++){
				if(es[i].checked){
					ids.push(es[i].value);
				}
			}
			if(ids.length < 1){showTip('请选择日志');return;}
			if( confirm("准备提交数据，是否继续？") ){
				Mask.show();
				document.location.href = "<%=request.getContextPath()%>/protected/system/delActionLog.action?ids="+ids.join(",");
			}
		}
		</sec:authorize>
		$(document).ready(function(){
			Administry.contextBoxInit();
			
			//AutoComplete操作日志名关键字输入框
			$("#s_actionName").autocomplete(
			'<%=request.getContextPath()%>/protected/system/autoCompleteForNameActionLog.action',
			{
				width: 160,
				max: 10,
				scroll: true,
				scrollHeight: 300,
				dataType: 'json',
				parse: function(data) {
					if(!isArray(data)){
						data = eval("("+data+")");
					}
					var rows = [];
					for(var i=0; i<data.length; i++){
						rows.push({
							"data" : data[i],
							"value" : data[i],
							"result" : this.formatResult && this.formatResult(data[i], data[i]) || data[i]
						});
					}
					return rows;
				},
				formatItem: function(data, i, total) {
					return data;
				}
			});
			$("#s_userName").autocomplete(
			'<%=request.getContextPath()%>/protected/system/autoCompleteForUserActionLog.action',
			{
				width: 160,
				max: 10,
				scroll: true,
				scrollHeight: 300,
				dataType: 'json',
				matchCase:true,
				parse: function(data) {
					if(!isArray(data)){
						data = eval("("+data+")");
					}
					var rows = [];
					for(var i=0; i<data.length; i++){
						rows.push({
							"data" : data[i],
							"value" : data[i][1],
							"result" : this.formatResult && this.formatResult(data[i], data[i][0]) || data[i][0]
						});
					}
					return rows;
				},
				formatItem: function(data, i, total) {
					var truename = data[1] || null;
					var nickname = data[2] || null;
					var item = data[0];
					if(truename) item += " | " + truename;
					if(nickname) item += " | " + nickname;
					return item;
				}
			});
		});
	</script>
</head>
<body>
	<%@include file="/include/body.jsp" %>
	
<s:if test="flag">
	<!-- 显示操作成功 -->
	<script type="text/javascript">
		showTip("操作成功");
	</script>
</s:if>

<!-- Wrapper -->
<div class="wrapper">
	
    <div class="content-box resizable" id="query_area">
    	<header>
			<h3>搜索</h3>
		</header>
		<section>
		<table class="no-style">
			<tbody>
			<tr>
				<td>
		        	<span>操作日志名:
		        		<input id="s_actionName" type="text" name="s_actionName" value="<s:property value="actionName"/>" class="input input_wa" />
		        	</span>
		        	<span>操作人员:
		        		<input id="s_userName" type="text" name="s_userName" value="<s:property value="userName"/>" class="input input_wa" />
		        	</span>
		        	<span>起始日期:
		        		<input id="s_startDate" type="text" name="s_startDate" onfocus="WdatePicker({startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'});" class="input input_wa" value="<s:property value="startDate"/>"/>
		        	</span>
		        	<span>结束日期:
		        		<input id="s_endDate" type="text" name="s_endDate" onfocus="WdatePicker({startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd'});" class="input input_wa" value="<s:property value="endDate"/>" />
		        	</span>
		            <span>
						<button class="btn" type="submit" onclick="doSearch();"><span class="icon icon-search"></span>搜 索</button>
					</span>
				</td>
			</tr>
			</tbody>
		</table>
		</section>
	</div>
	<div class="content-box" id="show_area">
	<header>
		<h3>
			<span>操作日志列表</span>
	    	<span>排序：
	    		<s:select id="orderby" value="orderby" onchange="doSearch();" theme="simple" 
		   			list="#{' order by l.actionTime desc':'操作时间：降序',' order by l.actionTime asc':'操作时间：升序',' order by l.actionName asc':'操作名'}">
		   		</s:select>
	    	</span>
		</h3>
		<div>
		 <sec:authorize ifAnyGranted="ADMIN,ACTIONLOG_DELETE">
	    	<span>
	    		<span>
	    			<a class="btn btn-gray" href="javascript:void(0)" onclick="doSearch();"><span class="icon icon-refresh"></span>刷新</a>
	    		</span>
	    		<span>
	    			<a class="btn" href="javascript:void(0)" onclick="del();"><span class="icon icon-del"></span>删除所选日志</a>
	    		</span>
	    	</span>
	    </sec:authorize>
	    </div>
    </header>
    <section>
    <table class="stylized" id="data_table" style="width:100%;">
    	<col width="30"></col>
    	<col width="40"></col>
    	<col width="80"></col>
    	<col width="80"></col>
    	<col width="100"></col>
    	<col width="50"></col>
    	<col width="auto"></col>
     	<thead>
		<tr>
			<th><input type="checkbox" name="all_cbx" title="全选 " onclick="checkAll(this, 'code_cbx')"/></th>
			<th>序号</th>
			<th>操作名</th>
			<th>操作人员</th>
			<th>操作时间</th>
			<th>操作IP</th>
			<th>详细</th>
		</tr>
		</thead>
		<tbody>
		<s:if test="logs != null">
		<s:iterator value="logs" status="logstatus">
			<tr>
			<td><input type="checkbox" name="code_cbx" value="<s:property value="id"/>"/></td>
			<td><s:property value="#logstatus.index + 1 +start"/></td>
			<td><s:property value="actionName"/></td>
			<td><s:property value="user"/></td>
			<td><s:date name="actionTime" format="yyyy-MM-dd HH:mm"/></td>
			<td><s:property value="IP"/></td>
			<td>
				<div class="longText"><s:property value="detail"/></div>
			</td>
			</tr>
		</s:iterator>
		</s:if>
		</tbody>
	</table>
	<div id="page_bar"></div>
	</section>
	</div>
</div>

</body>
</html>